#include "bhxjglpie.h"

BHXJGLPie::BHXJGLPie():BHXJGLModel()
{

}
void BHXJGLPie::Init(BHXJGLFUN *glcore, unsigned int num)
{
    this->gl=glcore;

    auto arr=BHXJGLModelHelper::getCirclePoints(num);

    BHXJGLMesh *m=new BHXJGLMesh();

    BHXJGLVertex v;
    v.position=glm::vec3(0);
    v.texcoodr=glm::vec2(0.5);
    m->vertices.push_back(v);
    for(unsigned int i=0;i<arr->size();++i)
    {
        //顶点
        v.position=arr->at(i);
        v.normal=glm::vec3(0,0,1);
        v.texcoodr=glm::vec2(v.position.x/2+0.5f,v.position.y/2+0.5f);
        m->vertices.push_back(v);
    }

    BHXJGLModelHelper::addPieToMesh(m,0,1,num,BHXJFront);

    //加入网格并初始化
    this->meshes.push_back(m);
    m->Init(this->gl);

    BHXJGLTexture2D *texture=new BHXJGLTexture2D();
    this->textures.push_back(texture);
    m->textures.push_back(texture);
    texture->Init(gl,"./texture/123.jpeg");
}


